import { ElNotification, ElMessageBox, ElMessage } from 'element-plus'
import { type NotificationParams } from 'element-plus'

// 屏幕中部消息提示
// ElMessage('This is a message.')
// ElMessage.success('This is a success message.')
// ElMessage.warning('This is a warning message.')
// ElMessage.info('This is an info message.')
// ElMessage.error('This is an error message.')
// ElMessage({
//   message: 'Warning, this is a warning message.',
//   type: 'warning',
// })

// <el-popconfirm title="是否确认要删除吗?" :width="150" @confirm=""> <template #reference>delete</template> </el-popconfirm>

// 消息提示 屏幕右边
export function showMessage(
  message: string,
  type: 'success' | 'warning' | 'info' | 'error' = 'success',
  dangerouslyUseHTMLString: boolean = false,
  duration: number = 3000
) {
  ElNotification({
    title: '', // 添加必要的title属性
    message,
    type,
    dangerouslyUseHTMLString,
    duration
  } as NotificationParams)
}

// 确认对话框
export function showModal(content: string, title = '', type: 'success' | 'warning' | 'info' | 'error' = 'warning') {
  return ElMessageBox.confirm(content, title, {
    confirmButtonText: '确定', // 确定按钮文字
    cancelButtonText: '取消', // 取消按钮文字
    type
  })
}

// 弹出输入框
export function showPrompt(quession: string, value = '', title = '') {
  return ElMessageBox.prompt(quession, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    inputValue: value
  })
}
